#ifndef __UTILITY_H
#define __UTILITY_H

#include <sys/types.h>
#include <stdarg.h>

int util_snprintf(char *buf, ssize_t buflen, const char *format, ...);
int util_vsnprintf(char *buf, ssize_t buflen, const char *format, va_list ap);

#define MAX_MESSAGE_SIZE 1024


#if (!defined max) && (!defined min)
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
    __typeof__ (b) _b = (b); \
    _a > _b ? _a : _b; })

#define min(a,b) \
({ __typeof__ (a) _a = (a); \
    __typeof__ (b) _b = (b); \
    _a < _b ? _a : _b; })

#endif  //!max min

#endif  //!__UTILITY_H